

import java.util.Scanner;
//********************************************************************
//	 listSort.java		Based on Lewis / Loftus
//	 Sorts arrays
//  Shell for Assignment 3
//********************************************************************


public class ListSort
{
	//-----------------------------------------------------------------
	// Constructor
	//-----------------------------------------------------------------


	//登录菜单　
	public void showLogin()
	{
		System.out.println("\t\t欢迎使用学生管理系统");
		System.out.println("\t\t*****************************");
		while(true){
			Scanner sc = new Scanner(System.in);
			System.out.println("\t\t姓名:");
			String name = sc.next();
			System.out.println("\t\t密码:");
			/*Eraser e = new Eraser('*');
			Thread eraserThread = new Thread(e);
			eraserThread.start();*/
			String password =sc.next();
		//	e.setActive(false);
			//System.out.println();
			if("user".equals(name)&&"user".equals(password))
			{
				System.out.println("\t\t%s,您已经登录成功!\n\n");
				showMain();
				
			}else
			{
				System.out.println("\t\t您的登录名或密码错误,请重新尝试!\n");
				showLogin();
			}
			
			
			
			
		}
	}

	public void showMain() {
		System.out.println("\t\t欢迎使用学生管理系统");
		System.out.println("\t\t1.学生列表");
		System.out.println("\t\t2.增加学生");
		System.out.println("\t\t返回请按0,退出该系统请按9请选择您需要的菜单（1,2,0,9）：");
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		switch(num){
		case 1:
			showStuList();break;
		case 2:
			showStuAdd();break;
		case 9:
			System.exit(0);
		case 0:
			showLogin();break;
		
		default:
			System.out.println("\t\t输入错误，请重新尝试");
			showMain();
		}
	}

	private void showStuAdd() {
		StudentEnrol st = new StudentEnrol();
		st.addStudent();
		
	}

	private void showStuList() {
		System.out.println("\t\t学生列表");
		UserManager rw = new UserManager();
		System.out.println("| firstName |\t LastName |\t ID | \t\tMajor \t free |");
		rw.read(System.getProperty("user.dir")+"/File3.txt");
		showMain();
	}
	
	
	
	public ListSort()
		{
		}

	//-----------------------------------------------------------------
	// Method for testing that class has been reached
	// This should be removed from your final program 	
	//-----------------------------------------------------------------	
	public boolean listSortReached(){
			return true;			
		}
		
    } // end of listSort class 
//-----------------------------------------------------------------
